TOOL.Category		= "Cosmos"
TOOL.Name			= "#Gravity Plating"
TOOL.Command		= nil
TOOL.ConfigName		= nil

TOOL.ClientConVar[ "gravity" ] = "1";

if( CLIENT ) then
	
	language.Add( "Tool_cosmos_gravity_name", "Gravity Plating" );
	language.Add( "Tool_cosmos_gravity_desc", "Make a prop have artifical gravity." );
	language.Add( "Tool_cosmos_gravity_0", "Left click on a prop to give it artificial gravity. Right click on one to clear." );
	
end

function TOOL:LeftClick( tr )
	
	if( !tr.Entity or !tr.Entity:IsValid() ) then return end
	if( CLIENT ) then return true end
	
	local phys = tr.Entity:GetPhysicsObject();
	
	if( !phys or !phys:IsValid() ) then return end
	
	tr.Entity.GravityPlating = true;
	tr.Entity.GravityPlatingForce = self:GetClientNumber( "gravity" );
	return true
	
end

function TOOL:RightClick( tr )
	
	if( !tr.Entity or !tr.Entity:IsValid() ) then return end
	if( CLIENT ) then return true end
	
	local phys = tr.Entity:GetPhysicsObject();
	
	if( !phys or !phys:IsValid() ) then return end
	
	tr.Entity.GravityPlating = false;
	return true
	
end

function TOOL:Reload( tr )
	
	return true
	
end

function TOOL:BuildCPanel()
	
	local gravity = vgui.Create( "DNumSlider" );
	gravity:SetText( "Force (G)" );
	gravity:SetMin( 0.3 );
	gravity:SetMax( 5 );
	gravity:SetDecimals( 1 );
	gravity:SetConVar( "cosmos_gravity_gravity" );
	self:AddItem( gravity );
	
end
